<?php
/**
 * 后台中的控制器的父类。类里面处理一下公共的成员变量和成员函数
 * @author hanxiaojun
 * 
 */
class CommonControl extends Control{
	// 当前项目的域名
	var $domain = null;
	// 每页显示的数据
	var $page_size = 20;
	// 页码显示数
	var $pageDisplay = 10;
	// 赋值到模板
	var $out = array();
	//定义用户信息变量
	var $user_info = array();
	
	// 初始化后台数据
	function __construct(){
		parent::__construct ();
		$this->domain = DOMAIN;
		$this->smarty->assign ('domain', $this->domain);
		$this->user_info = $_SESSION['user'];
	}
	
	//重新smarty的成员方法，方便调用
	function display($tpl){
		$this->smarty->assign('out',$this->out);
		$this->smarty->display($tpl);
	}
	function fetch($tpl){
		$this->smarty->assign('out',$this->out);
		return $this->smarty->fetch($tpl);
	}
	
	
	
	
	
	// 页面提示信息
	function alert($msg){
		echo '<script>alert("' . $msg . '");window.history.back();</script>';
	}
	
	function close($msg = ''){
		if ($msg == '')
			echo '<script>window.close();</script>';
		else
			echo '<script>alert("' . $msg . '");window.close();</script>';
	}
	function pinfo($info){
		echo "<script>
		var obj;
		if (top.infoFrame) obj = top.infoFrame;
		else if (window.opener.top.infoFrame) obj = window.opener.top.infoFrame;
		else if (window.opener.opener.top.infoFrame) obj = window.opener.opener.top.infoFrame;
		else obj = null;
		if (obj) {
		var info = obj.document.getElementById('info');
		info.innerHTML = info.innerHTML + '$info<br>';
		obj.scroll(0, 99999);
	}
	</script>";
	}
	function pmain($url){
		if ($url == 'reload'){
			echo "<script>top.mainFrame.location.reload();</script>";
		}else{
			echo "<script>top.mainFrame.location='$url';</script>";
		}
	}
	function ptop($url){
		if ($url == 'reload'){
			echo "<script>top.location.reload();</script>";
		}else{
			echo "<script>top.location='$url';</script>";
		}
	}
}